let pageNum = 1;
function render(pageNum) {
  $.ajax({
    url: "/recipe",
    method: "get",
    data: {
      pageNum: pageNum,
      pageSize: 15,
    },
    success(res) {
      console.log(res);
      let str = "";
      $.each(res.data.list, function (i, item) {
        str += ` <li>
    <a href="info.html" data-id='${item.id}'>
      <img src="http://124.223.14.236:3001/public/food/list-${item.id}.jpg" alt="" />
      <h3>${item.name}</h3>
    </a>
  </li>`;
      });
      $(".list-box").append(str);
    },
  });
}
render(pageNum);
window.addEventListener("scroll", function () {
  let top = $(window).scrollTop();
  if (top > 100) {
    pageNum++;
    render(pageNum);
  }
});
// 点击a获取id值跳转
$(".list-box").on("click", "a", function () {
  const id = $(this).attr("data-id");
  localStorage.setItem("meauId", id);
});
